package Thread;

public class Demo3 {
    //匿名内部类实现，与方法一了类似
    public static void main(String[] args) throws InterruptedException {
    Thread t1=new Thread(){
        public void run(){
            while(true){
                System.out.println("t1 running");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        }
    };
    t1.start();
    while(true){
        System.out.println("main running");
        Thread.sleep(1000);
    }
    }
}
